package com.hyzh.latte.vehicle.config;

import com.coffee.concurrent.CoffeeExecutorManager;
import com.hyzh.latte.vehicle.service.NezhaRecordService;
import com.hyzh.latte.vehicle.service.NezhaService;
import com.hyzh.latte.vehicle.nezha.ParkDeviceBuilder;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;



/**
 * @author: songkui
 * @since: 2024/3/21 00:47
 */
@Component
@Order(1)
@Slf4j
@AllArgsConstructor
public class StartInitialize implements ApplicationRunner {

    private final NezhaService nezhaService;

    private final NezhaRecordService nezhaRecordService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        CoffeeExecutorManager.getInstance().disruptor(8).scheduler().slowExecutor();
        ParkDeviceBuilder.builder()
                .poleMap(nezhaService.mapPoleVertex())
                .poleEdgeMap(nezhaService.mapPoleEdg())
                .cameraMap(nezhaService.mapCamera())
                .parkMap(nezhaService.parkList())
//                .pointMap(nezhaService.pointMap())
                .gateMap(nezhaService.gateMap())
                .poleEntityMap(nezhaService.poleEntityMap())
                .parkEntityMap(nezhaService.mapPark())
                .nezhaRecordService(nezhaRecordService)
                .vtypeMap(nezhaService.vtype())
                .build()
                .verify().initialize();
    }

}
